package other;


import org.junit.Test;
import org.springframework.core.ResolvableType;

import java.util.HashMap;
import java.util.List;

public class SpringOtherDemo {

    private String test;

    private HashMap<Integer, List<String>> myMap;
    @Test
    public void resolvableTypeDemo(){
        try{
            ResolvableType t = ResolvableType.forField(getClass().getDeclaredField("myMap"));
            System.out.println(t.getType().getTypeName());
            System.out.println(t.getSuperType()); // AbstractMap<Integer, List<String>>
            System.out.println(t.asMap()); // Map<Integer, List<String>>
            System.out.println(t.getGeneric(0).resolve()); // Integer
            System.out.println(t.getGeneric(1).resolve()); // List
            System.out.println(t.getGeneric(1)); // List<String>
            System.out.println(t.resolveGeneric(1, 0)); // String
//            ResolvableType methodType = ResolvableType.forMethodReturnType(getClass().getMethod("resolvableTypeDemo"));
//            System.out.println(methodType.getType().getTypeName());
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
